package com.kx.hackathon.service.impl;

import com.kx.hackathon.service.HandlerService;
import com.kx.hackathon.util.Expression;
import org.springframework.stereotype.Service;

@Service("CalculatorServiceImpl")
public class CalculatorServiceImpl implements HandlerService {


    @Override
    public String handle(String msg, String arg) {
        try {
            Expression expression = new Expression(arg);
            return " = " + expression.calculate();
        }catch (Exception e){
            return "没算出来，你这个表达式有毛病吧";
        }
    }

    @Override
    public String init(String msg, String arg) {
        return null;
    }

    @Override
    public boolean needInit() {
        return false;
    }
}
